package edu.msse.signup.service;

import java.util.Date;

import javax.jws.WebService;

import edu.msse.signup.domain.Event;
import edu.msse.signup.domain.Position;


@WebService(endpointInterface = "edu.msse.signup.service.VolunteerWebService")
public class VolunteerWebServiceImpl implements VolunteerWebService{
	EventService eventService;
	
	
	

	@Override
	public int createEvent(Event e) {
		String Name=e.getName();
		String Description=e.getDescription();
		Date StartDate=e.getStartDate();
		Date StartTime=e.getStartDate();
		Date EndDate=e.getEndDate();
		Date EndTime=e.getEndDate();
		
		Event newEvent=eventService.createEvent(Name, Description, StartDate, StartTime, EndDate, EndTime, null);
		return newEvent.getEventId();
	}

	@Override
	public int createAndAssignPositionToEvent(Position p, Event e) {
		//create event
		try{
			String Name=e.getName();
		
		String Description=e.getDescription();
		Date StartDate=e.getStartDate();
		Date StartTime=e.getStartDate();
		Date EndDate=e.getEndDate();
		Date EndTime=e.getEndDate();
		
		Event newEvent=eventService.createEvent(Name, Description, StartDate, StartTime, EndDate, EndTime, null);
		
		//create position
		String name=p.getName();
		String description=p.getDescription();
		int numberOfVolunteers=p.getNumberOfVolunteers();
		Event event=newEvent;
		
		Position currentPosition = PositionService.createPosition(name, description, numberOfVolunteers, event);
		EventService.addPosition(event, currentPosition);
		}
		catch(Exception E){
			E.printStackTrace();
			return 0;
		}
		return 1;
	}




	
	
}
